
if exists (select 1 from sysobjects where name = 'set_copydienstschema' and type = 'P')
begin
   drop procedure set_copydienstschema
   print 'Procedure: set_copydienstschema deleted ...'
end
go
create procedure set_copydienstschema(
  @oldschemaid      int = 1,
  @newschemaid      int = 1
)
as
begin

   set nocount on

   insert DienstSchema
   select schemaid      = @newschemaid,
          abteilungid   = ds.abteilungid,
          dienstid      = ds.dienstid,
          einsatzprotag = ds.einsatzprotag,
          gerechnet     = ds.gerechnet
     from dienstschema ds
    where ds.schemaid = @oldschemaid

end
go
print 'Procedure: set_copydienstschema done ...'
go
grant exec on set_copydienstschema to prsadmins with grant option
go
grant exec on set_copydienstschema to prsusers
go

